package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetMealDishMapper {
    //根据菜品id查询对应的套餐id（可能为多对多）
    List<Long> getSetMealIdsByDishIds(List<Long> dishIds);

    //根据菜品id查询对应的套餐id（必定为多单对单）
    @Select("select setmeal_dish.setmeal_id from setmeal_dish where dish_id = #{dishId}")
    Long getSetMealIdByDishId(Long dishId);

    //批量保存套餐和菜品的关联关系
    void insertBatch(List<SetmealDish> setmealDishes);

    //在删除套餐时，批量删除套餐内所有的菜品
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Long id);

    //根据套餐id查询包含的所有菜品
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getSetmealDishesBySetmealId(Long id);
}
